#!/usr/bin/env bash

NPM_HEADER="Accept: application/vnd.npm.install-v1+json"
NPM_REGISTRY="https://registry.npmjs.org"
OLDER_THAN="1y"
OLDER_THAN_DATE=$(date -v-${OLDER_THAN} '+%Y-%m-%d')

jq -r '.devDependencies | keys[]' < package.json | \
  xargs -r -I{} curl -sSH "${NPM_HEADER}" "${NPM_REGISTRY}/{}" | \
  jq 'select(.modified | . < "'"${OLDER_THAN_DATE}"'") | pick(.name, .modified)'
